package com.example.xiaomiao.Mapper;

import com.example.xiaomiao.DO.Picture;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PictureMapper {
    @Select("select picture_id from picture where md5 = #{md5}")
    Integer getPictureId(@Param("md5") String md5);

    @Select("select p.picture_id,p.md5 from picture p left join user u on p.picture_id = u.profile_picture " +
            "where u.user_id is null")
    List<Picture> getWildPicture();

    @Insert("insert into picture(md5) values (#{picture.md5})")
    @Options(useGeneratedKeys = true, keyProperty = "picture_id")
    void addPicture(@Param("picture") Picture pictureMessage);

    void deleteByMD5s(@Param("md5s") List<String> md5s);
}
